package com.jishuo.nontax.web.bill;

import com.jishuo.base.annotation.UserAuthority;
import com.jishuo.base.bean.BaseResult;
import com.jishuo.base.bean.GridResult;
import com.jishuo.base.bean.Pagination;
import com.jishuo.nontax.bean.vo.DeductVO;
import com.jishuo.nontax.bfc.service.DeductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 批扣
 * @auther dinggaofei
 * @Date 2023/3/15 8:41
 */
@Slf4j
@Controller
@RequestMapping(value = "/bill/deduct",name = "通用罚没")
@UserAuthority(menu = {"bill/deduct","sys/basedata/basedata"})
public class DedectController {
    @Resource
    private DeductService deductService;

    // 页面文件位置
    private String prefix = "bill/";

    @RequestMapping(value = {"deduct", "deduct/{page}"}, name = "化解分成首页")
    public String index(@PathVariable(required = false) String page) {
        return prefix + ((page == null) ? "deduct" : page);
    }


    @ResponseBody
    @RequestMapping(value = "findDeductPage",name = "批扣列表")
    public GridResult<DeductVO> findDeductPage(DeductVO deductVO, Pagination pagination){
        return  new GridResult<>(deductService.findDeductPage(deductVO,pagination));
    }

    @ResponseBody
    @RequestMapping(value = "saveDeduct",name = "修改批扣信息")
    public BaseResult saveDeduct(DeductVO deductVO){
        return  deductService.saveDeduct(deductVO);
    }

    @ResponseBody
    @RequestMapping(value = "getDeduct",name = "根据id获取批扣信息")
    public BaseResult getDeduct(Long deductid){
        return  new BaseResult(deductService.getDeduct(deductid));
    }
    @ResponseBody
    @RequestMapping(value = "sendDeduct",name = "发送批扣信息")
    public BaseResult sendDeduct(@RequestParam List<String> billids, String userpwd, String usercode){
        return  deductService.findSendDeduct(billids,userpwd,usercode);
    }

    @ResponseBody
    @RequestMapping(value = "cleanDeduct",name = "冲销批扣信息")
    public BaseResult cleanDeduct(@RequestParam List<String> billids, String userpwd, String usercode){
        return  deductService.cleanDeduct(billids,userpwd,usercode);
    }

    @ResponseBody
    @RequestMapping(value = "deductExport",name = "导出批扣信息")
    public void  deductExport(@RequestParam List<String> billids, HttpServletResponse response){
          deductService.deductExport(billids,response);
    }
}
